home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / gdm / Init / Default
Encoding:
Text File  |  2009-04-03  |  2.6 KB  |  90 lines

  1. #!/bin/sh
  2. # Stolen from the debian kdm setup, aren't I sneaky
  3. # Plus a lot of fun stuff added
  4. #  -George
  5.  
  6. PATH=/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH
  7. OLD_IFS=$IFS
  8.  
  9. gdmwhich () {
  10.   COMMAND="$1"
  11.   OUTPUT=
  12.   IFS=:
  13.   for dir in $PATH
  14.   do
  15.     if test -x "$dir/$COMMAND" ; then
  16.       if test "x$OUTPUT" = "x" ; then
  17.         OUTPUT="$dir/$COMMAND"
  18.       fi
  19.     fi
  20.   done
  21.   IFS=$OLD_IFS 
  22.   echo "$OUTPUT"
  23. }
  24.  
  25. sysresources=/etc/X11/Xresources
  26.  
  27. # merge in defaults
  28. if [ -f "$sysresources" ]; then
  29.     xrdb -merge "$sysresources"
  30. fi
  31.  
  32. sysmodmap=/etc/X11/Xmodmap
  33.  
  34. XMODMAP=`gdmwhich xmodmap`
  35. if [ "x$XMODMAP" != "x" ] ; then
  36.   if [ "x$GDM_PARENT_DISPLAY" = "x" ]; then
  37.     if [ -f $sysmodmap ]; then
  38.       $XMODMAP $sysmodmap
  39.     fi
  40.   else
  41.     ( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $XMODMAP -pke ) | $XMODMAP -
  42.   fi
  43.  
  44.   #
  45.   # Switch Sun's Alt and Meta mod mappings
  46.   #
  47.  
  48.   UNAME=`gdmwhich uname`
  49.   PROCESSOR=`$UNAME -p`
  50.   if [ "x$PROCESSOR" = "xsparc" ]; then
  51.     if $XMODMAP | /usr/bin/grep mod4 | /usr/bin/grep Alt > /dev/null 2>/dev/null
  52.     then
  53.       $XMODMAP -e "clear Mod1" \
  54.                -e "clear Mod4" \
  55.                -e "add Mod1 = Alt_L" \
  56.                -e "add Mod1 = Alt_R" \
  57.                -e "add Mod4 = Meta_L" \
  58.                -e "add Mod4 = Meta_R"
  59.     fi
  60.   fi
  61. fi
  62.  
  63. SETXKBMAP=`gdmwhich setxkbmap`
  64. if [ "x$SETXKBMAP" != "x" ] ; then
  65.   # FIXME: is this all right?  Is this completely on crack?
  66.   # What this does is move the xkb configuration from the GDM_PARENT_DISPLAY
  67.   # FIXME: This should be done in code.  Or there must be an easier way ...
  68.   if [ -n "$GDM_PARENT_DISPLAY" ]; then
  69.     XKBSETUP=`( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $SETXKBMAP -v )`
  70.     if [ -n "$XKBSETUP" ]; then
  71.       XKBKEYMAP=`echo "$XKBSETUP" | grep '^keymap' | awk '{ print $2 }'`
  72.       XKBTYPES=`echo "$XKBSETUP" | grep '^types' | awk '{ print $2 }'`
  73.       XKBCOMPAT=`echo "$XKBSETUP" | grep '^compat' | awk '{ print $2 }'`
  74.       XKBSYMBOLS=`echo "$XKBSETUP" | grep '^symbols' | awk '{ print $2 }'`
  75.       XKBGEOMETRY=`echo "$XKBSETUP" | grep '^geometry' | awk '{ print $2 }'`
  76.       if [ -n "$XKBKEYMAP" ]; then
  77.         $SETXKBMAP -keymap "$XKBKEYMAP"
  78.       elif [ -n "$XKBTYPES" -a -n "$XKBCOMPAT" -a -n "$XKBSYMBOLS" -a -n "$XKBGEOMETRY" ]; then
  79.         $SETXKBMAP -types "$XKBTYPES" -compat "$XKBCOMPAT" -symbols "$XKBSYMBOLS" -geometry "$XKBGEOMETRY"
  80.       elif [ -n "$XKBTYPES" -a -n "$XKBCOMPAT" -a -n "$XKBSYMBOLS" ]; then
  81.         $SETXKBMAP -types "$XKBTYPES" -compat "$XKBCOMPAT" -symbols "$XKBSYMBOLS"
  82.       elif [ -n "$XKBSYMBOLS" ]; then
  83.         $SETXKBMAP -symbols "$XKBSYMBOLS"
  84.       fi
  85.     fi
  86.   fi
  87. fi
  88.  
  89. exit 0
  90.